<?php require_once 'source.php';?>
<?php require_once 'config.php';?>
<?php require_once 'dao/dao_get_teachers_schedule.php';?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SYSTITLE?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css" />


</head>
<body>
<div class="wrapper">
<?php require_once 'header.php';?>
<div id="layout">
	<div id="leftlay"><?php require_once 'leftnav.php';?></div>
	<div id="rightlay">
		<div class="columntitle"><?php echo VIEWSCHEDULE?></div>
		<div class="columncontent">
			<table id="schedule" cellpadding="0" cellspacing="0" border="0">
				<tr>
					<th width="30"></th>
					<th width="150"><?php echo MON?></th>
					<th width="150"><?php echo TUE?></th>
					<th width="150"><?php echo WED?></th>
					<th width="150"><?php echo THU?></th>
					<th width="150"><?php echo FRI?></th>
					<th width="150"><?php echo SAT?></th>
					<th width="150"><?php echo SUN?></th>
				</tr>
				<?php 
					$linenum=0;
					$result=query_schedule($_SESSION['userid']);
					for($i=1;$i<=5;$i++){ 												// 5rows
						echo "<tr><th height='30'>".++$linenum.'-'.++$linenum."</th>";
						for($m=1;$m<=7;$m++){
				?>
				<td>
				<?php 
					$temp=$i.'-'.$m;
					if($_SESSION['level']==TEACHER){
						while(($row=mysql_fetch_array($result))!=FALSE){
							if($row['lessonindex']==$temp){
								if($row['STARTWEEK']!=''&&$row['ENDWEEK']!=''){
									if($row['STARTWEEK']<=currentweek()&&$row['ENDWEEK']>=currentweek()){
										echo $row['username'].' ';
									}
								}else{
									echo $row['username'].' ';
								}
								
							}
						}
					mysql_data_seek($result,0);
					}
				?>
				</td>
			<?php 
		}
		echo "</tr>";
	}
	mysql_close();
			?>			
			</table>
		</div>
	</div>
</div>
<?php require_once 'footer.php';?>
</div>
</body>
</html>